<?php
/**
 * Created by PhpStorm.
 * User: lelouchms
 * Date: 2019/6/3
 * Time: 10:46
 */

namespace app\index\controller;


use app\common\exception\CustomerException;
use app\common\model\UserRepairType;

class UserRepair extends Base
{

    public function initialize()
    {
        parent::initialize();
    }

    public function types()
    {
        return (new UserRepairType())->select();
    }

    public function add()
    {
        $requestData = $this->request->only(['username', 'phone', 'remark', 'house_id', 'type_id']);
        $requestData['user_id'] = session("web_user")['id'];
        $validate = new \app\common\validate\UserRepair();
        if (!$validate->scene("add")->check($requestData)) {
            throw new CustomerException($validate->getError());
        }
        (new \app\common\model\UserRepair())->save($requestData);
        return "报修成功";
    }


}